<!doctype html>
<html class="draggable">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vite App</title>
    <style>
      .draggable {
        -webkit-app-region: drag;
      }

      html,
      body {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
        background: transparent;
        -webkit-app-region: drag; /* 整个窗口可拖拽 */
      }

      #app {
        position: absolute;
        top: 0;
        left: 0;
        width: 100px;
        height: 100px;
        border-radius: 50%;
        background-color: red;
        user-select: none;
        cursor: move;
        transition:
          transform 0.1s ease,
          box-shadow 0.1s ease;
        /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); */
      }

      /* 拖动时的样式 */
      #app:active {
        transform: scale(0.95);
        /* box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1); */
        background-color: #ff3333;
      }

      /* 鼠标悬停效果 */
      #app:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
      }

      /* 右键菜单按钮 */
      .menu-button {
        position: fixed;
        top: 5px;
        right: 5px;
        width: 20px;
        height: 20px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 50%;
        cursor: pointer;
        -webkit-app-region: no-drag; /* 按钮区域不可拖拽 */
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        color: #666;
        transition: all 0.2s ease;
      }

      .menu-button:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(1.1);
      }
    </style>
  </head>
  <body>
    <div id="app"></div>
    <div class="menu-button" id="menuButton">≡</div>
    <script type="module" src="/src/main.ts"></script>
    <script>
      const { ipcRenderer } = require('electron')
      const app = document.getElementById('app')
      const menuButton = document.getElementById('menuButton')

      // 右键菜单按钮点击事件
      menuButton.addEventListener('click', (e) => {
        e.preventDefault()
        ipcRenderer.send('show-context-menu')
      })

      // 双击事件
      app.addEventListener('dblclick', () => {
        const currentColor = app.style.backgroundColor
        app.style.backgroundColor = currentColor === 'red' ? '#ff4444' : 'red'
      })
    </script>
  </body>
</html>
